#include "NewtonInterp.h"

int main(int argc, char* argv[]){
  cout << "Test for interpolating by all datas :" << endl;
  NewtonInterp<double> NI1;
  InterpConditions<double,1> IC;
  vector<vector<double> > doubleTab;
  double tmp1[4] = {0,1,2,4};
  vector<double> doubleVec0(tmp1,tmp1+4);
  vector<double> doubleVec1(4,6);
  doubleVec1[1] = 5;
  doubleVec1[2] = 14;
  doubleVec1[3] = 86;
  doubleTab.push_back(doubleVec0);
  doubleTab.push_back(doubleVec1);
  vector<vector<bool> > boolTab;
  vector<bool> boolVec0(4,1);
  vector<bool> boolVec1(4,1);
  boolTab.push_back(boolVec0);
  boolTab.push_back(boolVec1);
  IC.setTable(doubleTab,boolTab);
  NewtonInterp<double> NI2(IC);
  cout << "NI2 input: " << endl;
  cout << NI2.getPreConditions();
  double d2[4] = {6,-4,2,1};
  vector<double> vec2(d2,d2+4);
  Polynomial<double> Poly2(vec2);
  cout << "expect :" << Poly2 << endl;
  cout << "result :" << NI2.getInterPoly() << endl;
  NewtonInterp<double> NI3("Inputfile/testfile/test3");
  cout << "NI3 input: " << endl;
  cout << NI3.getPreConditions();
  double d3[5] = {-1,1,-1,1,1};
  vector<double> vec3(d3,d3+5);
  Polynomial<double> Poly3(vec3);
  cout << "expect :" << Poly3 << endl;
  cout << "result :" << NI3.getInterPoly() << endl;
  cout << "Test for interpolating by adding point :" << endl;
  NewtonInterp<double> NI4("Inputfile/testfile/test4");
  cout << "NI4 input: " << endl;
  cout << NI4.getPreConditions();
  cout << "result :" << NI4.getInterPoly() << endl;
  cout << "Add a point (-2,1)." << endl;
  NI4.addPoint(-2,1);
  cout << "NI4 new input: " << endl;
  cout << NI4.getPreConditions();
  cout << "expect :" << Poly3 << endl;
  cout << "result :" << NI4.getInterPoly() << endl;
  cout << "Test for Neville-Aitken algorithm :" << endl;
  NewtonInterp<double> NI5("Inputfile/testfile/test5");
  cout << "NI5 input: " << endl;
  cout << NI5.getPreConditions();
  cout << "Interpolating result :" << NI5.getInterPoly() << endl;
  cout << "value at 1.5 = " << NI5.getInterPoly().getValue(1.5) << endl;
  cout << "By using  Neville-Aitken algorithm, result at 1.5 = " << NI5.NevilleAitken(1.5,"Inputfile/testfile/test5") << endl;
}
